<?php
// +----------------------------------------------------------------------
// | zlserver [ 小程序 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2018 http://www.zhongliansoft.com All rights reserved.
// +----------------------------------------------------------------------
// | Author: tony <tanyu@zhongliansoft.com>
// +----------------------------------------------------------------------
/**
 * 校检token
 */
namespace app\manage\behavior;

use think\Db;
use think\facade\Request;
use think\facade\Log;

class ValidateToken
{
    //需要校检的控制器和方法
    private function getConf()
    {
        //结构：控制器@方法名
        return [
            'administrator@add',
            'administrator@edit',
            'apartment@dormadd',
            'apartment@dormedit',
            'apartment@dormuseradd',
            'apartment@entrustuseradd',
            'article@add',
            'article@edit',
            'articletype@add',
            'articletype@addson',
            'articletype@edit',
            'book@addbookinfo',
            'book@editbookinfo',
            'bookassistant@assistantuseradd',
            'bookdraw@bookextradrawbookreladd',
            'bookdraw@bookpredrawedit',
            'bookdraw@extradrawsave',
            'bookdraw@extratypeadd',
            'bookdraw@extratypeedit',
            'bookdraw@extratypeparamadd',
            'bookdraw@extratypeparamedit',
            'bookdraw@predrawsave',
            'bookdraw@supplyaddbook',
            'bookdraw@supplydrawsave',
            'bookreturn@bookreturn',
            'bookreturn@drawreturnreturn',
            'bookreturn@bookadjust',
            'bookplan@batcheditnum',
            'bookplan@batcheditprice',
            'bookplan@copy',
            'bookplan@edit',
            'bookplan@savebooknum',
            'bookplan@savebookprice',
            'bookreturn@bookreturn',
            'bookreturn@drawreturnreturn',
            'carousel@add',
            'carousel@edit',
            'carouselseat@add',
            'carouselseat@edit',
            'dept@add',
            'dept@edit',
            'hooks@add',
            'hooks@edit',
            'messagecenter@edit',
            'notice@add',
            'notice@edit',
            'operation@add',
            'operation@edit',
            'planstudentrel@edit',
            'planstudentrel@editrel',
            'position@add',
            'position@edit',
            'role@add',
            'student@edit',
            'user@adduser',
            'user@edituser',
            'userrole@add',
            'wxoperation@add',
            'wxoperation@edit'
        ];
    }

    public function run($params)
    {
        if (Request::isPost()) {
            $validateMethod = $this->getConf();
            $ctl          = strtolower(Request::controller());
            $act          = strtolower(Request::action());
            if (in_array($ctl . '@' . $act, $validateMethod)) {
                $data = validateZlServerToken();
            }
        }
    }

}